//
// Created by 吴喆 on 2020/3/1.
//

#ifndef SUMMER_CONSOLE_H
#define SUMMER_CONSOLE_H

#include <iostream>
#include <string>
/**
 * 用于输出控制台信息
 */
#define _INFO(out, _a, _f, _line) Console::info(out, _a, _f, _line)
#define INFO(content) _INFO(std::cout, content, __FILE__, __LINE__)
#define errLog(content) _INFO(std::cerr, content, __FILE__, __LINE__)
class Console {
public:
    template <typename T, typename V>
    static inline void info(T& t, const V text, const char *file, int line) {
        static_assert(std::is_base_of_v<std::ostream, T>, "必须继承自ostream");
        t << "-------------------------------------------------------" << std::endl;
        t << "address:" << file << ":" << line << std::endl;
        t << text << std::endl;
        t << "-------------------------------------------------------" << std::endl;
    }
    static inline void welcome(int port, bool isMain) {
        std::cout << "***********"<< (isMain?"master":"slave") <<"********************************************"  << std::endl;
        std::cout << "*   ||   ||                   ======        ===    ======  *"  << std::endl;
        std::cout << "*   ||   ||  " << "port:" << port << "        ||           《      ||       *"  << std::endl;
        std::cout << "*   ||   ||  ____  || \\\\   // ======   | /  ===    ======    *"  << std::endl;
        std::cout << "*   \\\\   // ||  || ||  \\\\ //  ||       |/      》  ||         *"  << std::endl;
        std::cout << "*    =====  ||  || ||    V    ======   ||   ===    ======      *"  << std::endl;
        std::cout << "*****************************************************************"  << std::endl;
    }

};


#endif //SUMMER_CONSOLE_H
